package mylibrary.algorithm.insertionSort;

import java.util.*;

public class InsertionSort {

	public static void main(String[] args) {
		
		int array[] = {5,4,3,6,1,7,4};
		sortDesc(array);
		for(int i=0; i<array.length; i++) {
			System.out.println(array[i]);
		}
		
		HashMap map = new HashMap();
		map.equals(map);
	}
	
	public static void sortAsc(int[] array) {
		
		for(int j=1; j<array.length; j++) {
			
			int temp = array[j];
			
			int i = j - 1;
			while(i>=0 && array[i]>temp) {
				array[i+1] = array[i];
				i = i-1;
			}
			array[i+1] = temp;
		}
	}
	
public static void sortDesc(int[] array) {
		
		for(int j=1; j<array.length; j++) {
			
			int temp = array[j];
			
			int i = j - 1;
			while(i>=0 && array[i]<temp) {
				array[i+1] = array[i];
				i = i-1;
			}
			array[i+1] = temp;
		}
	}
}
